import { fileURLToPath, URL } from "url";

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import styleImport, { VantResolve } from 'vite-plugin-style-import';
const path = require("path");
// https://vitejs.dev/config/
export default defineConfig({
  define: {
    'process.env': {}
  },
  plugins: [vue(), vueJsx(),styleImport({
    resolves: [VantResolve()],
  })],
  css: {
    preprocessorOptions: {
        less: {
            modifyVars: {
                hack: `true; @import (reference) "${path.resolve("src/style/index.less")}";`,
            },
            javascriptEnabled: true,
        },
    },
  },
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  base: './',
  server: {
    port: 4000, // 设置服务启动端口号
    open: true, // 设置服务启动时是否自动打开浏览器
    cors: true // 允许跨域
  }
});


// module.exports = {   
//   publicPath: process.env.NODE_ENV === 'production' ? './' : './'  
// };  